import java.util.*;

class Bill{
	ArrayList<Item> l=new ArrayList<Item>();
	float amount;
	
	public Bill(){
		amount=0;
	}
	
	public void addItem(String itemCode,String itemName,float price){
		l.add(new Item(itemCode,itemName,price));
		amount=getAmount()+price;
		
	}
	
	public void deleteItem(String code){
		Iterator<Item> itr=l.iterator();
		while(itr.hasNext()){
			Item ele=itr.next();
			if(ele.getItemCode().equals(code)){
				amount=getAmount()-ele.getPrice();
				itr.remove();
				
			}
		}
	}
	
	public float getAmount(){
		return amount;
	}
	
	public String displayBill(){
		String s="";
		for(Item i:l) {
                       s=s+i+"\n";
		}
		return s;
	}
	
	public int noOfItems(){
		return l.size();
	}
}

